<?php

class Artikel extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model('model_artikel', 'martikel');
        $this->load->helper('url');
        $this->load->library('session');
        $this->config->load('artyproperty');
        $this->_public_view = $this->config->item('public_view');
    }

    function index() {
        //cek session
        $islogin = $this->session->userdata('isLogin');
        $user = '';
        if ($islogin) {
            $user = $this->session->userdata('username');
        }

        $data = array('daftar' => $this->martikel->get_artikel(),
            'page_content' => 'view_artikel',
            'page_title' => 'Daftar Artikel',
            'isLogin' => $islogin,
            'user' => $user);
        $this->load->view($this->_public_view, $data);
    }

    function detail() {
        $str_id = '';
        //cek session
        $islogin = $this->session->userdata('isLogin');
        $user = '';
        if ($islogin) {
            $user = $this->session->userdata('username');
        }

        if ($this->uri->segment(3) == FALSE) {
            redirect('artikel', 'location');
        } else {
            $str_id = $this->uri->segment(3);
        }

        $data = array('detail' => $this->martikel->get_artikel_detail($str_id),
            'page_content' => 'detail_artikel',
            'page_title' => 'Detail Artikel',
            'isLogin' => $islogin,
            'user' => $user);
        $this->load->view($this->_public_view, $data);
    }

}

?>
